define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_list(result){
			if(false){
				result = '{"success": true,"msg": "","result": {"store_count": "500","data": [{"goods_id": 1,"name": "十字螺丝刀","introduce": "十字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "./img/upload/pro-img01.jpg","storenumber": 100,"salenumber": 20,"personlimit": 3,"qq": "1234567","phone": "18912345678","popularity":8},{"goods_id": 2,"name": "一字螺丝刀","introduce": "一字螺丝刀","price": 5.5,"mktprice": 8,"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "./img/upload/pro-img01.jpg","storenumber": 80,"salenumber": 10,"personlimit": 3,"qq": "1234567","phone": "18912345678","popularity":8}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//获取推荐商品分类
		function get_data_goodstype(result){
            if(false){
                result = '{"success": true,"msg": "","result":{"type": [{"id":1,"name":"管理软件"},{"id":2,"name":"办公软件"},{"id":3,"name":"培训"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }
        }

		//获取快递公司
		function get_data_logisticscomp(result){
            if(false){
                result = '{"success": true,"msg": "","result":"","session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }
        }
        //查询快递
        function get_data_logistics(result){
            if(false){
                result = '{"success": true,"msg": "","result":"","session": "7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }
        }


		//返回信息
		return {
			//获取商品推荐数据
			get_list: function(cat_type, key, nPage,recommend_id ,callback,calldone) {
				Http.post({
					method:"goods.search.getlist",
					cat_type: cat_type,
					key: key,
					pagelimit:10,
					nPage:nPage,
					recommend_id:recommend_id
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_list(result).result);
				},function(err){

				},function(){
					if(calldone)
						calldone();
				});
			},
			get_goodstype:function(callback){
			   Http.post({
			       method:"goods.recommend.goodstype",
			   }, function(result) {
                    //函数回调
                    if(callback)
                        callback(get_data_goodstype(result).result);
                },function(err){

                },function(){
                    
                });
			},
			//快递公司列表
			get_logisticscomp:function(callback){
			    Http.post({
                   method:"member.logisticscomp.getlist",
                   pagelimit:-1
               }, function(result) {
                    if(callback)
                        callback(get_data_logisticscomp(result).result);
                },function(err){

                },function(){
                   
                });
			},
			//查询快递
			get_logistics:function(com_id,logistics_no,callback){
			    Http.post({
                   method:"logistics.getlist",
                   com_id:com_id,
                   logistics_no:logistics_no
               }, function(result) {
                    if(callback)
                        callback(get_data_logisticscomp(result).result);
                },function(err){

                },function(){
                    if(calldone)
                        calldone();
                });
			},
			//获取用户信息
			getUserInfo: function(callback) {
				Http.post({
					method: 'member.get',
				}, function(result) {
					if(callback)
						callback(result.result);
				}, function(e) {

				}, function() {
					
				})
			}
			

		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Themember", factory);
});